/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jsf;

import bean.OrderDetailBean;
import bean.ShipBean;
import cart.CartItem;
import ejb.OrderDetail;
import ejb.Ship;
import java.math.BigDecimal;
import java.util.List;
import javax.faces.model.SelectItem;

/**
 *
 * @author owner
 */

public class OrderController {

    /** Creates a new instance of OrderController */
    public OrderController() {
    }

    private OrderDetail currentOrderDetail;

    public OrderDetail getCurrentOrderDetail() {
        return currentOrderDetail;
    }


    public void addOrder()
    {
        OrderDetailBean odb = new OrderDetailBean();
        odb.createOrderDetail(currentOrderDetail);
    }

    public String callOrderBean()
    {
        CartItem ci = new CartItem();
        ci.toOrderDetail();
        addOrder();
        return "toOrderDetail";
    }

    private Ship currentShip;
    private String shipId;

    public String getShipId() {
        return shipId;
    }

    public void setShipId(String shipId) {
        this.shipId = shipId;
    }

    public void setCurrentShip(Ship currentShip) {
        this.currentShip = currentShip;
    }
    

    public Ship getCurrentShip() {
        return currentShip;
    }

    public SelectItem[] getShipSelectItems()
    {
        ShipBean sb = new ShipBean();
        List<Ship> ships = sb.getAllShip();

        SelectItem[] items = new SelectItem[ships.size()];
        int i = 0;

        for(Ship s : ships)
        {
            items[i] = new SelectItem(s,s.getShipVia());
            i++;
        }
        return items;
    }
}
